import request from '@/util/ProRequest'

// 获取权限列表
export function getProductionOrderList(params) {
    return request({
        url: '/productionOrder/page',
        method: 'get',
        params
    })
}

export function addProductionOrder(data) {
    return request({
        url: '/productionOrder/add',
        method: 'post',
        data
    })
}

// 根据ID查询工单详情
export function getProductionOrderById(id) {
    return request({
        url: `/productionOrder/${id}`,
        method: 'get'
    })
}

export function updateProductionOrder(data) {
    return request({
        url: '/productionOrder/update',
        method: 'put',
        data
    })
}

export function queryByCode(code) {
    return request({
        url: '/productionOrder/code/' + code,
        method: 'get'
    })
}

//根据工单编号删除工单
export function deleteProductionOrder(id) {
    return request({
        url: '/productionOrder/delete/' + id,
        method: 'delete'
    })
}

export function batchDeleteProductionOrder(ids) {
    return request({
        url: '/productionOrder/batchDelete?' + ids,
        method: 'delete',
    })
}

// 获取自动生成的编号
export function getAutoCode() {
    return request({
        url: '/productionOrder/autoCode',
        method: 'get'
    })
}

/*BOM组成和物料需求*/
export const getProductionOrderBom = params => request({url: '/bom/page', method: 'get', params})
export const getProductionOrderMaterialReq = params => request({
    url: '/productionOrder/materialReq',
    method: 'get',
    params
})


/**
 * 审核生产工单
 * @param id
 * @returns {*}
 */
export function auditProductionOrder(id) {
    return request({
        url: `/productionOrder/audit/${id}`,
        method: 'put'
    })
}
